from book.models import  BookInfo, PeopleInfo
BookInfo.objects.get(id=1)
BookInfo.objects.get(id=5)
BookInfo.objects.all()
BookInfo.object.count()
BookInfo.object.count()


BookInfo.objects.get(id__exact=1)
BookInfo.objects.get(id=1)
BookInfo.objects.get(pk=1)

BookInfo.objects.filter(name__contains='传')
BookInfo.objects.filter(name__endswith='部')
BookInfo.objects.filter(name__startswith='射')

BookInfo.objects.filter(name__isnull=True)
BookInfo.objects.filter(name__isnull=False)

BookInfo.objects.filter(id__in=[1, 2, 3])
BookInfo.objects.filter(id__gt=3)
BookInfo.objects.filter(id__lt=3)

BookInfo.objects.exclude(id=3)

BookInfo.objects.filter(pub_date__year=1980)
BookInfo.objects.filter(pub_date__gt='1990-1-1')

from djano.db models import F, Q
BookInfo.objects.filter(readcount__gte=F('commentcount'))
BookInfo.objects.filter(readcount__gte=F('commentcount')*2)
BookInfo.objects.filter(readcount__gt=20, id__lt=3)
BookInfo.objects.filter(Q(readcount__gt=20) | Q(id__lt=3))
BookInfo.objects.filter(~Q(id=3))
BookInfo.objects.filter(~Q(id__in=[1, 3]))
from django.db.models import Sum ,Max ,Avg ,Count ,Min
BookInfo.objects.filter(readcount__gte=F('commentcount'))
BookInfo.objects.filter(readcount__gte=F('commentcount')*2)
BookInfo.objects.filter(readcount__gt=20, id__lt=3)
BookInfo.objects.filter(Q(readcount__gt=20) | Q(id__lt=3))
BookInfo.objects.filter(~Q(id=3))
BookInfo.objects.filter(~Q(id__in=[1, 3]))
from django.db.models import Sum, Max, Avg, Count, Min
BookInfo.objects.aggregate(Sum('readcount'))
BookInfo.objects.aggregate(Max('commentcount'))
BookInfo.objects.aggregate(Avg('readcount'))
BookInfo.objects.all()
BookInfo.objects.all().order_by('readcount')
BookInfo.objects.all().order_by('-commentcount')
BookInfo.objects.all().order_by('pub_date')
BookInfo.objects.all().order_by('-pub_date')
from django.db.models import F, Q
BookInfo.objects.filter(readcount__gte=F('commentcount')*2)
BookInfo.objects.filter(readcount__gt=20, id__lt=3)
BookInfo.objects.filter(Q(readcount__gt=20) | Q(id__lt=3))
BookInfo.objects.filter(~Q(id=3))
BookInfo.objects.filter(~Q(id__in=[1, 3]))
book = BookInfo.objects.get(id=1)
book.peopleinfo_set.all()
book = BookInfo.objects.get (name=' 雪山飞狐 ')
book.peopleinfo_set.all ()
people = PeopleInfo.objects.get(id=1)
people.book
people.book_id
people = PeopleInfo.objects.get (name=' 虚竹 ')
people.book